package LecoLi.Util.Item01;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.demo.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Le Co on 2017/5/10.
 */

public class viewPagerAdapter extends PagerAdapter {
    private int[] datas;
    private Context context;
    public viewPagerAdapter(Context context,int[] datas){
         this.context=context;
         this.datas=datas;
    }
    @Override
    public int getCount() {
        return datas.length;
    }


    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        ImageView imageView = new ImageView(context);
        imageView.setImageResource(datas[position]);
        container.addView(imageView);
        return imageView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);

    }
}
